<?xml version="1.0"?>
<jsp:root 	xmlns:jsp="http://java.sun.com/JSP/Page"
 			xmlns:c="http://java.sun.com/jsp/jstl/core"
 			xmlns="http://www.w3.org/1999/xhtml"
 			version="2.1">
 
 <jsp:directive.page contentType="text/html" pageEncoding="UTF-8" />
 <jsp:directive.page isELIgnored="false" />
 <jsp:output 	omit-xml-declaration="false" 
 			 	doctype-root-element="HTML" 
 				doctype-system="about:legacy-compat" />
 
 <jsp:useBean id="datosLogin" class="es.javamyadmin.beans.LoginBean" scope="session" />
 
 <jsp:useBean id="listaTablesBean" class="es.javamyadmin.beans.ListaTablesBean" scope="session" />
 
 <jsp:setProperty property="user" name="listaTablesBean" value="${datosLogin.usuario}" />
 <jsp:setProperty property="pass" name="listaTablesBean" value="${datosLogin.password}" />
 <jsp:setProperty property="host" name="listaTablesBean" value="${datosLogin.servidor}" />
 <jsp:setProperty property="port" name="listaTablesBean" value="${datosLogin.puerto}" />
 
 <c:if test="${(param.bd != null) and (param.bd != '')}">
 	<jsp:setProperty property="database" name="listaTablesBean" value="${param.bd}" />
 </c:if>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="icon" href="${pageContext.request.contextPath}/images/icons/favicon.png" type="image/x-icon"/>
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/icons/favicon.png" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/reset.css" media="screen" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/java-admin.css" media="screen" />

<script src="${pageContext.request.contextPath}/js/jquery.js"><!-- N --></script>
<script src="${pageContext.request.contextPath}/js/bootstrap-transition.js"><!-- N --></script>
<script src="${pageContext.request.contextPath}/js/bootstrap-modal.js"><!-- N --></script>
<script src="${pageContext.request.contextPath}/js/ajaxCargarMsjConfirmacion.js"><!-- N --></script>

<title>JavaMyAdmin</title>

<script>
	$(document).ready(function() {
		$('#windowTitleDialog').bind('show', function () {
			
		});
	});
	function closeDialog () {
		$('#windowTitleDialog').modal('hide'); 
	};
	function okClicked () {
		window.location='${pageContext.request.contextPath}/eliminarBD';
		closeDialog ();
	};
	
	function okClicked2 () {
		
		closeDialog ();
	};
	
	function okClicked3 () {
		
		closeDialog ();
	};
</script>

</head>

<body onload="cargarTablas('${listaTablesBean.user}','${listaTablesBean.pass}','${listaTablesBean.host}','${listaTablesBean.port}','${listaTablesBean.database}');">

<div id="wrapper">
<div id="todo">

<div id="contenedor">
	
	<jsp:include page="../includes/sidebar-left.jsp" />
	
	<div id="contenido">
	
		<jsp:include page="../includes/cabecera.jsp" />
		
		<h2>Base de Datos: <c:out value="${listaTablesBean.database}"></c:out></h2>
		
		<jsp:include page="../includes/menu-superior.jsp" />
		
		<!-- Errores -->
		<c:if test="${error!=null}"><div id="ko"  class="aviso"><div class="pro_aviso ko"><p>${error }<c:if test="${descripcion != null}"><a id="especial" data-toggle="modal" href="#windowTitleDialog" onclick="cargarDatosMsj('6', '${descripcion}', '');" style="font-size:'10px'; "> (más)</a></c:if></p></div></div></c:if>		
		<c:if test="${ok!=null}"><div class="aviso"><div class="pro_aviso ok"><p><c:out value="${ok}"></c:out></p></div></div></c:if>
		
		<!-- VENTANA EMERGENTE DE CONFIRMACIÓN -->
		<div id="windowTitleDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="windowTitleLabel" aria-hidden="true">
			<!-- se cargará el mensaje por ajax -->
		</div>
		<!-- FIN VENTANA EMERGENTE -->
				
		<table id="lista-tablas">		
			<tr>
				<th class="inicio">TABLAS</th>
				<th>FILAS</th>
				<th>COTEJAMIENTO</th>
				<th>TIPO</th>
				<th class="fin">ACCIONES</th>
			</tr>
		
			<c:choose>
				<c:when test="${listaTablesBean.tables.size()!=0}">
					<c:forEach var="lista" items="${listaTablesBean.tables}" varStatus="estado">			
						<tr>
							<td align="center"><form action="${pageContext.request.contextPath}/jsp/contenido-tablas-bd.jsp" id="flsit${estado.index }" method="post" ><input type="hidden" name="bd" value="${param.bd }" /><input type="hidden" name="tabla" value="${lista.nombreTable}" /><a href="#" onclick="document.getElementById('flsit${estado.index }').submit();"><c:out value="${lista.nombreTable}"></c:out></a></form></td>
							<td align="center"><c:out value="${lista.numFilas}"></c:out></td>
							<td align="center"><c:out value="${lista.cotejamiento}"></c:out></td>
							<td align="center"><c:out value="${lista.tipo}"></c:out></td>
							<td align="center">
							<div style="margin: 0 auto; width: 100px;">
							<div style="float: left;">
								<form action="${pageContext.request.contextPath}/jsp/detalle-tablas-bd.jsp" method="post">
									<input type="hidden" name="bd" value="${listaTablesBean.database }" />
									<input type="hidden" name="tabla" value="${lista.nombreTable }" />
									<input title="ver tabla" type="image" class="margen" src="${pageContext.request.contextPath}/images/icons/ver.png" width="20" height="20" alt="ver"/>
								</form>
							</div>
							<div style="float: left;">
								<form action="${pageContext.request.contextPath}/jsp/alter-tablas-bd.jsp" method="post">
									<input type="hidden" name="bd" value="${listaTablesBean.database }" />
									<input type="hidden" name="tabla" value="${lista.nombreTable }" />
									<input title="editar tabla" type="image" class="margen" src="${pageContext.request.contextPath}/images/icons/editar.png" width="20" height="20" alt="editar"/>
								</form>
							</div>
							<div style="float: left;">
								<a data-toggle="modal" href="#windowTitleDialog" onclick="cargarDatosMsj('2', '${lista.nombreTable}', '');" title="eliminar tabla"><img class="margen" src="${pageContext.request.contextPath}/images/icons/eliminar.png" width="20" height="20" alt="eliminar"/></a>
							</div>
							<div style="float: left;">
								<a data-toggle="modal" href="#windowTitleDialog" onclick="cargarDatosMsj('3', '${lista.nombreTable}', '');" title="vaciar tabla"><img class="margen" src="${pageContext.request.contextPath}/images/icons/vaciar.png" width="20" height="20" alt="vaciar"/></a>
							</div>
							</div>
							<div style="clear: both;"></div>
							</td>
						</tr>
					</c:forEach>
				</c:when>
				
				<c:when test="${listaTablesBean.tables.size()==0}">
					<tr>
						<td colspan="5" align="center">No existe ninguna tabla en esta Base de Datos.</td>
					</tr>
				</c:when>
			</c:choose>
			
			
			
	 	</table>
	 	
	 	<form style="margin-top: 30px;" action="${pageContext.request.contextPath}/validarCrearTabla" method="post">
	 		<table>
	 			<tr>
					<td colspan="5"><img class="arrow" src="${pageContext.request.contextPath}/images/arrow.png"  id="crearTabla" />Crear nueva Tabla</td>
				</tr>
				
				<tr>
					<td>Nombre</td>
					<td><input class="campo" type="text" name="nombreTabla" id="nombreNuevaTabla"/></td>
					<td>Número de campos</td>
					<td><input class="campo" type="text" name="numCampos"/></td>
					<td><input class="boton" type="submit" value="Crear"/></td>
				</tr>				
	 		</table>
	 	</form>
	 		
	</div>

</div>

</div>
</div>
</body>
<c:if test="${param.f ==true }">
<script>
document.getElementById('nombreNuevaTabla').focus();
</script>
</c:if>
</html>
</jsp:root>